#include "Window.h"
#include "Client.h"

#ifndef SCREEN_DIMENSIONS
#define SCREEN_DIMENSIONS
#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 400
#endif

using namespace std;

Window *Window::p_Window = NULL; // I use this trick a lot
HWND Window::s_hWnd = NULL;
////////////////////WINDOWPROC
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
return Client::p_Client->HandleEvents(hwnd, uMsg,wParam,lParam);
//return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
/////////////////////CONSTRUCTOR
Window::Window(){}; //placeholder...i think...
Window::Window(HINSTANCE Instance,int iCmdShow){
p_Window = this;
S_Width = SCREEN_WIDTH;
S_Height =SCREEN_HEIGHT;


WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
wc.style  = CS_OWNDC;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = Instance;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);//default
wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);//default
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
wc.lpszClassName = L"ClassName";
wc.lpszMenuName = NULL;

RegisterClassEx(&wc);
s_hWnd = CreateWindowEx(
        0,                              // Optional window styles.
        L"ClassName",                     // Window class
        L"Game",    // Window text
        WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,            // Window style

        // Size and position
        200, 100,
		S_Width+GetSystemMetrics(SM_CXFIXEDFRAME)*2,
        S_Height+GetSystemMetrics(SM_CYFIXEDFRAME)*2+GetSystemMetrics(SM_CYCAPTION),
        NULL,       // Parent window
        NULL,       // Menu
        Instance,  // Instance handle
        NULL        // Additional application data
        );


if(s_hWnd != NULL){

ShowWindow(s_hWnd,iCmdShow);
UpdateWindow(s_hWnd);
}

}
/////////////////////DESTRUCTOR
Window::~Window(){};



